//
//  HYCSingleton.m
//  FamilyTravel
//
//  Created by dllo on 15/10/31.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "HYCSingleton.h"

@implementation HYCSingleton

+ (instancetype)shareSingleton {
    static HYCSingleton *single = nil;
    static dispatch_once_t oneToTake;
    dispatch_once(&oneToTake, ^{
        
        single = [[HYCSingleton alloc] init];
    });
    return single;
}

- (void)setIsNight:(BOOL)isNight {
    _isNight = isNight;
    if (isNight) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"NIghtDay" object:nil];
    }else {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"LightDay" object:nil];
    }
    
}

- (void)saveNightModelInfoToDisk {
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    
    NSString *nightStr = nil;
    if (self.isNight) {
        nightStr = @"yse";
    }else {
        nightStr = @"no";
    }
    [user setObject:nightStr forKey:@"isNight"];
    // 这里建议同步储存到磁盘.但是不是必须的
    
    [user synchronize];
    
}

- (void)loadNightModelInfoToDisk {
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    
    NSString *nightStr = [user objectForKey:@"isNight"];
    self.isNight = [nightStr isEqualToString:@"yes"];
}


























@end
